package com.wuliu.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuliu.common.annotation.Log;
import com.wuliu.common.core.controller.BaseController;
import com.wuliu.common.core.domain.AjaxResult;
import com.wuliu.common.enums.BusinessType;
import com.wuliu.system.domain.TolPush;
import com.wuliu.system.service.ITolPushService;
import com.wuliu.common.utils.poi.ExcelUtil;
import com.wuliu.common.core.page.TableDataInfo;

/**
 * 公众号/小程序推送记录Controller
 * 
 * @author realue
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/system/push")
public class TolPushController extends BaseController
{
    @Resource
    private ITolPushService tolPushService;

    /**
     * 查询公众号/小程序推送记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:push:list')")
    @GetMapping("/list")
    public TableDataInfo list(TolPush tolPush)
    {

        startPage();
        List<TolPush> list = tolPushService.selectTolPushList(tolPush);
        return getDataTable(list);
    }

    /**
     * 导出公众号/小程序推送记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:push:export')")
    @Log(title = "公众号/小程序推送记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TolPush tolPush)
    {
        List<TolPush> list = tolPushService.selectTolPushList(tolPush);
        ExcelUtil<TolPush> util = new ExcelUtil<TolPush>(TolPush.class);
        util.exportExcel(response, list, "公众号/小程序推送记录数据");
    }

    /**
     * 获取公众号/小程序推送记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:push:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tolPushService.selectTolPushById(id));
    }

    /**
     * 新增公众号/小程序推送记录
     */
    @PreAuthorize("@ss.hasPermi('system:push:add')")
    @Log(title = "公众号/小程序推送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TolPush tolPush)
    {
        return toAjax(tolPushService.insertTolPush(tolPush));
    }

    /**
     * 修改公众号/小程序推送记录
     */
    @PreAuthorize("@ss.hasPermi('system:push:edit')")
    @Log(title = "公众号/小程序推送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TolPush tolPush)
    {
        return toAjax(tolPushService.updateTolPush(tolPush));
    }

    /**
     * 删除公众号/小程序推送记录
     */
    @PreAuthorize("@ss.hasPermi('system:push:remove')")
    @Log(title = "公众号/小程序推送记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tolPushService.deleteTolPushByIds(ids));
    }
}
